{include file='admin/before_body.phtml' title='后台首页'}
{include file='admin/header.phtml'}
    <div class="main-container" id="main-container">
      <script type="text/javascript">try { ace.settings.check('main-container' , 'fixed') }catch(e) {  }</script>
      <div class="main-container-inner">
        {include file='admin/sidebar.phtml' navigation='dashboard'}
        <div class="main-content">
{$breadcrumbs=[]}
{$breadcrumbs[] = ['name' => '用户设置', 'icon' => 'icon-home home-icon']}
{$breadcrumbs[] = ['name' => '用户管理', 'link' => url('admin/user')]}
{$breadcrumbs[] = ['name' => '编辑用户', 'isactive' => true]}
{include file='admin/breadcrumb.phtml' breadcrumbs=$breadcrumbs}
{$editUser = $smarty.session['editUser']['data']|default:null}
{$role = $smarty.session['editUser']['role']|default:$role}
          <div class="page-content">
            {html_messages}
            <div class="page-header"><h1>用户[ {$user->username} ]资料</h1></div>
            <div class="row">
<div class="col-xs-12">
  <div class="user-profile row">
    <div class="col-xs-12 col-sm-offset-2 col-sm-3 center">
      <div>
        <span class="profile-picture">
          <img id="avatar" class="editable img-responsive" src="{$editUser['avatar']|default:$user->avatar}" />
        </span>
      </div>
    </div>
    <div class="col-xs-12 col-sm-7">
      <form class="form-horizontal" role="form" id="addform" method="POST">
        <input type="text" id="avatarback" name="avatar" hidden value="{$editUser['avatar']|default:$user->avatar}">
        <div class="form-group">
          <label class="col-sm-2 control-label no-padding-right"> 用户名 </label>
          <div class="col-sm-10">
            <input type="text" class="col-xs-10 col-sm-5" value="{$user->username}" disabled>
          </div>
        </div>
        <div class="space-4"></div>
        <div class="form-group">
          <label class="col-sm-2 control-label no-padding-right"> 昵称 </label>
          <div class="col-sm-10">
            <input type="text" class="col-xs-10 col-sm-5" name="nickname" value="{$editUser['nickname']|default:$user->nickname}">
          </div>
        </div>
        <div class="space-4"></div>
        <div class="form-group">
          <label class="col-sm-2 control-label no-padding-right"> 密码 </label>
          <div class="col-sm-10">
            <input type="password" class="col-xs-10 col-sm-5" name="password" value="{$editUser['password']|default:''}">
          </div>
        </div>
        <div class="space-4"></div>
        <div class="form-group">
          <label class="col-sm-2 control-label no-padding-right"> 状态 </label>
          <div class="col-sm-10">
            <input class="ace ace-switch ace-switch-7" value='1' name="status" type="checkbox" {if
              $editUser['status']|default:$user->status == '1'
            } checked="checked" {/if} />
            <span class="lbl"></span>
          </div>
        </div>
        <div class="space-4"></div>
        <div class="form-group">
          <label class="col-sm-2 control-label no-padding-right"> 角色 </label>
          <div class="col-sm-10">
            <select id="roleid" name="roleid" class="col-xs-10 col-sm-5">
              {if isset($role)}
                <option value="{$role['role_id']}">{$role['rolename']}</option>
              {/if}
              <option value=""></option>
            </select>
          </div>
        </div>
        <div class="clearfix form-actions" style="background: none;border-top: none;">
          <div class="col-md-offset-2 col-md-10">
            <button class="btn" type="reset"><i class="icon-undo bigger-110"></i>重置</button>
            <button class="btn btn-info" type="submit">
              <i class="icon-edit bigger-110"></i> 保存
            </button>
          </div>
        </div>
      </form>
    </div>
  </div>
</div>
</div><!-- /.col -->






            </div>
          </div>
        </div>
      </div>
    </div>
</body>
{include file='admin/after_body.phtml'}
{include file='admin/upload_image.phtml' showid="avatar" callbackid="avatarback" btnchoose="上传用户头像" type="adminhead"}


<script type="text/javascript">
  $('#addform').on('reset', function() {
    $('input[name="avatar"]').change();
  });


  $('#roleid').select2(LIVE.component.select2.config({
    placeholder: '请选择一个角色',
    ajax: {
      url : '{url('admin/user/role')}',
      data: function(params) {
        return {
          search: params.term,
          page: params.page, status: 1
        };
      },
      processResults: function (res, params) {
        params.page = params.page || 1;
        var data = res.result;
        return {
          results: data.roles.map(function(role) {
            return { id: role.role_id, text: role.rolename }
          }),
          pagination: {
            more: data.next
          }
        };
      },
    },
    language: {
      'noResults': function(){
        return '<span>找不到相关的角色，<a href="{url('admin/user/role/add')}">添加角色</a></span>';
      }
    },
  }));

  $('#addform').submit(function(e) {
    var data = LIVE.component.form.getData($(this));
    if (!data['avatar']) { return alert('请上传用户头像') || e.preventDefault();}
    data['nickname'] = data['nickname'] || data['username'];
    if (!data['roleid']) { return alert('请选择用户角色') || e.preventDefault();}
  });

</script>

</html>

